/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * Projects
 * Copyright (C) Arnaud Duval 2010 <arnaud.duval@gmail.com>
 * 
 * Projects is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Projects is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _DURATION_HPP_
#define _DURATION_HPP_

#include <DateTime.hpp>
#include <iostream>
#include <string>

///@class Duration
///@brief Defines a duration
///@warning The duration is limited to 10 hours for the moment
class Duration
{
    public:
        ///@brief Default constructor
        Duration();
        ///@brief Destructor
        ~Duration();
        ///@brief Overload of = operator
        Duration& operator=(const Duration&);
        ///@brief Return duration value in seconds
        double ValueInSeconds() const;
        ///@brief Return duration value in minutes
        double ValueInMinutes() const;
        ///@brief Return duration value in hours
        double ValueInHours() const;
        ///@brief Normalize the duration value
        void Normalize();
        ///@brief Set current Duration to the difference between two DateTime
        void Difference(DateTime, DateTime);
        ///@brief Overload of += operator
        void operator += (const Duration&);
        ///@brief Return hour value
        unsigned int GetHour();
        ///@brief Return minute value
        unsigned int GetMinute();
        ///@brief Return second value
        unsigned int GetSecond();
        ///@brief Return duration as text
        std::string AsText();
        ///@brief Set the duration object from a string with given format
        void SetWithFormat(std::string, std::string);
        ///@brief Set the hour value
        void SetHour(unsigned int);
        ///@brief Set the minute value
        void SetMinute(unsigned int);
        ///@brief Set the second value
        void SetSecond(unsigned int);
        ///@brief Reset duration value
        void Reset();

        ///@brief Overload of << operator
        friend std::ostream& operator<<(std::ostream &, const Duration&);
        ///@brief Overload of > operator
        friend bool operator>(const Duration&, const Duration&);
        ///@brief Overload of + operator : addition of a Duration object to a DateTime object
        friend DateTime operator+(const DateTime&, const Duration&);
    protected:

    private:
        unsigned int hour;
        unsigned int minute;
        unsigned int second;
};

#endif // _DURATION_HPP_
